package _spring_test._PropertyPlaceholder;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Properties;

/**
 * @Author: huangya
 * @Date: 2020/5/18
 * @Description:
 */
public class PropertyPlaceholderTest1 {

    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("PropertyPlaceholder/application-property-placeholder1.xml");
        User user = (User)ac.getBean("user");
        System.out.println(user.getName());

        PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = ac.getBean(PropertyPlaceholderConfigurer.class);
        propertyPlaceholderConfigurer.postProcessBeanFactory(((ClassPathXmlApplicationContext) ac).getBeanFactory());

        User user2 = (User)ac.getBean("user");
        System.out.println(user2.getName());
    }
}
